//
//  NetworkTools.swift
//  七哥直播
//
//  Created by seven on 2017/12/21.
//  Copyright © 2017年 seven. All rights reserved.
//

import Foundation
import Alamofire
import SwiftyJSON
enum MethodType {
    case get
    case post
}
class NetworkTools {
    static func requestData(_ type: MethodType, URLString: String, parameters: [String:Any]? = nil, finishedCallback: @escaping (_ result: JSON) -> ()){
        let method = type == .get ? HTTPMethod.get : HTTPMethod.post
        Alamofire.request(URLString, method: method, parameters: parameters).validate(contentType: ["text/plain"]).responseJSON { (response) in
            if let data = response.data{
                let jsonData = JSON(data)
                finishedCallback(jsonData)
            }else{
                print("无数据返回")
            }
        }
    }
}
